﻿Public Class FormKineticMeasurementHistoryList
    Dim obj As New clsLxjcInfo
    Public usr As String
    Dim txt As TextBox
    Private Sub FormKineticMeasurementHistoryList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim startDate As String = Date.Now.AddDays(-1).ToShortDateString()
        txtStartDate.Text = startDate
        Dim endDate As String = Date.Now.ToShortDateString()
        txtEndDate.Text = endDate
        setDgvData()
    End Sub

    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        setDgvData()
    End Sub

    Public Sub setDgvData()
        If String.IsNullOrEmpty(txtStartDate.Text.Trim()) = False And String.IsNullOrEmpty(txtEndDate.Text.Trim()) = False Then
            Dim dt As DataTable = obj.selectAll(txt_prod_id2.Text.Trim(), txt_steel_seal_no.Text.Trim(), txt_Name2.Text.Trim(),
                                                txtStartDate.Text.Trim(), txtEndDate.Text.Trim())
            dgv.AutoGenerateColumns = False
            dgv.DataSource = dt
        Else
            MsgBox("请输入开始时间和结束时间", vbYes, "提示")
        End If
    End Sub

    Private Sub dgv_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.CellDoubleClick
        If e.RowIndex > -1 And e.ColumnIndex > -1 Then
            Dim frmdetail As New FormKineticMeasurement
            Dim index As Integer = dgv.CurrentRow.Index
            Dim prodid As String = dgv.Rows(index).Cells("prod_id").Value
            frmdetail.ProdId = prodid
            frmdetail.usr = usr
            frmdetail.ShowDialog()
            Me.btnSearch.PerformClick()
        End If
    End Sub

    Private Sub btnSearchUpdate_Click(sender As Object, e As EventArgs) Handles btnSearchUpdate.Click
        If dgv.SelectedRows.Count > 0 Then
            Dim frm As FormKineticMeasurementUpdateHistoryList = New FormKineticMeasurementUpdateHistoryList()
            frm.Sys_id = dgv.SelectedRows(0).Cells("sys_id").Value.ToString()
            frm.ShowDialog(Me)
        End If
    End Sub

    Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs) Handles txtStartDate.MouseClick, txtEndDate.MouseClick
        txt = CType(sender, TextBox)
        DateNavigator1.Left = txt.Left
        DateNavigator1.Top = txt.Location.Y + txt.Height
        DateNavigator1.Visible = True
    End Sub

    Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs) Handles DateNavigator1.DateTimeChanged
        txt.Text = DateNavigator1.DateTime.ToShortDateString()
        DateNavigator1.Visible = False
    End Sub


End Class